From 73216cb91b7cd3a33d3121dcb6216d848b00221c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 14 Jun 2017 11:16:24 -0700 Subject: [PATCH] Hash `Kind` in metadata for crates This fixes what is now a bug in Cargo discovered when attempting to land rust-lang/rust#42495 where Cargo will compile both host and target artifacts with the same `-C metadata` flag. This means that the compile can load two crates with the same SVH that are supposed to be distinct, which causes weird bugs with crate loading and whatnot. This commit throws in the `Kind` into the metadata calculation to resolve this to ensure that host/target artifacts always have a different `-C metadata` --- src/cargo/ops/cargo_rustc/context.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index f569c1bef..fa1ddd004 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -477,6 +477,11 @@ impl<'a, 'cfg> Context<'a, 'cfg> { // settings like debuginfo and whatnot. unit.profile.hash(&mut hasher); + // Artifacts compiled for the host should have a different metadata + // piece than those compiled for the target, so make sure we throw in + // the unit's `kind` as well + unit.kind.hash(&mut hasher); + // Finally throw in the target name/kind. This ensures that concurrent // compiles of targets in the same crate don't collide. unit.target.name().hash(&mut hasher); -- 2.30.2